package com.lollipop.rabbitmq.eight;

import com.lollipop.rabbitmq.util.RabbitMqUtiils;
import com.rabbitmq.client.BuiltinExchangeType;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.DeliverCallback;

import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeoutException;

/**
 * @Author: Lollipop
 * @Date: 2021-10-06 17:02
 * @Description: 死信队列
 */
public class Consumer02 {
    public static final String DEAD_QUEUE = "dead_queue";

    public static void main(String[] args) throws IOException, TimeoutException {
        Channel channel = RabbitMqUtiils.getChannel();

        DeliverCallback deliverCallback = (consumerTag, message) -> {
            System.out.println("消费者Consoumer02接收到的消息：" + new String(message.getBody(), StandardCharsets.UTF_8) + "routingkey:" + message.getEnvelope().getRoutingKey());
        };
        channel.basicConsume(DEAD_QUEUE, true, deliverCallback, consumerTag -> {
        });
    }
}
